'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = (app) => {
  console.log('app.js ');
  const { router, controller, middleware, config } = app;
  const MDW_Auth_Token = middleware.auth(config);
  console.log('MDW_Auth_Token - ', MDW_Auth_Token);

  // socket-io egg
  // app.io.of('/').route('chat', app.io.controllers.chat);

  router.get('/', controller.home.index);
  router.get('/time', controller.home.time);

  router.get('/test', controller.test.index);
  router.get('/test/demo', controller.test.demo);

  // router.post('/common-api/common/index', controller.common.index);
  // router.post('/common-api/common/upload', controller.common.uploadFile);

  // 模拟通用接口
  router.get('/mock-api', controller.mock.index.detail);
  router.get('/mock-api/list', controller.mock.index.list);
  router.post('/mock-api/list', controller.mock.index.list);
  router.post('/mock-api/save', controller.mock.index.save);
  router.get('/mock-api/detail', controller.mock.index.detail);
  router.delete('/mock-api/delete', controller.mock.index.delete);

  router.get('/mock-api/auth/captcha', controller.mock.auth.captcha);
  router.get('/mock-api/auth/userList', controller.mock.auth.userList);
  router.post('/mock-api/auth/login', controller.mock.auth.login);
  router.post('/mock-api/auth/userInfo', MDW_Auth_Token, controller.mock.auth.userInfo);
  router.post('/mock-api/auth/loginOut', MDW_Auth_Token, controller.mock.auth.loginOut);
  router.post('/mock-api/auth/register', controller.mock.auth.register);

  router.get('/mock-api/tree2', controller.mock.tree.tree2);
  router.get('/mock-api/tree3', controller.mock.tree.tree3);

  router.get('/mock-api/area/provinces', controller.mock.area.provinces);
  router.get('/mock-api/area/cities', controller.mock.area.cities);
  router.get('/mock-api/area/areas', controller.mock.area.areas);
  router.get('/mock-api/area/streets', controller.mock.area.streets);
  router.get('/mock-api/area/villages', controller.mock.area.villages);
  router.get('/mock-api/area/pc', controller.mock.area.pc);
  router.get('/mock-api/area/pca', controller.mock.area.pca);
  router.get('/mock-api/area/pcas', controller.mock.area.pcas);

  router.get('/mock-api/map/carData', controller.map.carData);
};
